package com.library.controller;

import com.library.entity.Book;
import com.library.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/book")
public class BookController {
    
    @Autowired
    private BookService bookService;

    @RequestMapping("/list")
    public String list(Model model) {
        List<Book> books = bookService.findAllBooks();
        System.out.println(books.get(1).getBookname());
        model.addAttribute("books", books);
        return "index"; // 对应index.jsp
    }
}